package chapter3.No3_1_等待和通知机制.j生产者_消费者模式实现.demo1;

/**
 * Created by Administrator on 2016/11/19.
 */
public class C {
    Object lock;

    public C(Object lock) {
        this.lock = lock;
    }

    public void getValue() {
        synchronized (lock) {
            try {
                if (ValueObject.value.equals("")) {
                    lock.wait();
                }
                // get value
                System.out.println("get Value:"+ValueObject.value);
                ValueObject.value="";
                // 通知生产者去生产
                lock.notify();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
